package com.xqm.springcloud.config;
import com.xqm.springcloud.pojo.UserInfo;
import com.xqm.springcloud.service.UserInfoService;

import org.springframework.stereotype.Component;

import java.util.List;

import feign.hystrix.FallbackFactory;

/**
 * @author ShiMing
 * @version 1.0
 * @name MyFallBackFactory
 * @description TODO
 * @date 2020/8/21
 */

@Component
public class MyFallBackFactory implements FallbackFactory {

    @Override
    public UserInfoService create(Throwable throwable) {
        return new UserInfoService() {
            @Override
            public int deleteByPrimaryKey(String userId) {
                return 0;
            }

            @Override
            public int insert(UserInfo record) {
                return 0;
            }

            @Override
            public List<UserInfo> selectAll() {
                return null;
            }

            @Override
            public int updateByPrimaryKey(UserInfo record) {
                return 0;
            }

            @Override
            public UserInfo selectByPhone(String phone) {
                return new UserInfo().setUserNickname("您访问的服务已开启降级");
            }
        };
    }
}
